package com.aaa.controller;

import com.aaa.service.EmpDaoService;
import com.aaa.unilt.JwtUntil;
import com.aaa.vo.LoginVo;
import com.aaa.vo.Result;
import jdk.nashorn.internal.parser.Token;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: TODO
 * @date 2022/11/23
 */
@CrossOrigin
//必须连接数据库
@RestController
public class LoginController {

    @Autowired
    private EmpDaoService empDaoService;

    @PostMapping("/login")
    public Result login(@RequestBody LoginVo loginVo){

        return empDaoService.findByNameAge(loginVo);
//        if(loginVo.getUsername().equals("admin")&&loginVo.getPassword().equals("12345")){
//            //生成
//            Map<String,Object> map=new HashMap<>();
//            map.put("name",loginVo.getUsername());
//            String token = JwtUntil.createToken(map);
//            return new Result(2000,"登录成功",token);
//        }
//        return new Result(5000,"登录失败",null);
    }
}
